package com.techysky.repository;

import java.io.Serializable;
import java.util.List;


import org.springframework.data.jpa.repository.Query;

import com.techysky.entity.Question;

public interface QuestionRepository extends CoreRepository<Question, Serializable> {
	@Query(value="SELECT * from sys_question q where q.code=? order by RAND() LIMIT ?",nativeQuery=true)
	List<Question> findQuestionByRandom(String questionType,Integer r);
	@Query(value="SELECT t.id,t.content,t.A,t.B,t.C,t.D,t.E,t.answer,t.SEXPLAIN,t.code,t.name,t.entity_type,t.create_date,t.create_user,t1.order_code    FROM  sys_question t, sys_question_paper t1  WHERE	t.id = t1.question_id AND t1.paper_id =?1 and t.code=?2 ORDER BY t1.order_code",nativeQuery=true)
	List<Question> findSjByOrderCodeASC(String paperId,String code);
	
	@Query(value="SELECT  t.* FROM sys_question t, sys_question_paper t1 WHERE	t.id = t1.question_id AND t1.paper_id =?1 and t1.order_code=?2 ORDER BY t.CODE, t1.order_code  ",nativeQuery=true)
	List<Question> findtTm(String paperId, String orderCode);
	
	
	
	@Query(value="SELECT  t.* FROM sys_question t, sys_question_paper t1 WHERE	t.id = t1.question_id AND t1.paper_id =?1  ORDER BY t.CODE, t1.order_code  ",nativeQuery=true)
	List<Question> findAllQues(String paperId);
	List<Question> findByContent(String t_questionname);
	

	
}
